package com.ruoyi.web.controller.store.pan;

import com.ruoyi.common.annotation.RepeatSubmit;
import com.ruoyi.common.core.controller.BaseController;
import com.ruoyi.common.core.domain.AjaxResult;
import com.ruoyi.common.core.domain.entity.VendorSettlement;
import com.ruoyi.common.core.page.TableDataInfo;
import com.ruoyi.common.utils.poi.ExcelUtil;
import com.ruoyi.system.service.IVendorSettlementService;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.transaction.annotation.Transactional;
import org.springframework.web.bind.annotation.*;

import java.util.List;

/**
 * 【请填写功能名称】Controller
 *
 * @author wlmes
 * @date 2023-12-17
 */
@RestController
@RequestMapping("/system/settlement")
@Api(tags = "【请填写功能名称】相关接口")
public class VendorSettlementController extends BaseController
{
    @Autowired
    private IVendorSettlementService vendorSettlementService;


    /**
     * 查询【请填写功能名称】列表
     */
    @GetMapping("/list")
    @ApiOperation("查询【请填写功能名称】列表")
    public TableDataInfo list(VendorSettlement vendorSettlement)
    {
            startPage();
            List<VendorSettlement> list = vendorSettlementService.selectVendorSettlementList(vendorSettlement);
            return getDataTable(list);
    }

    /**
     * 导出【请填写功能名称】列表
     */
//    @PreAuthorize("@ss.hasPermi('system:settlement:export')")
    @GetMapping("/export")
    @ApiOperation("导出【请填写功能名称】列表")
    public AjaxResult export(VendorSettlement vendorSettlement)
    {
            List<VendorSettlement> list = vendorSettlementService.selectVendorSettlementList(vendorSettlement);
            ExcelUtil<VendorSettlement> util = new ExcelUtil<VendorSettlement>(VendorSettlement.class);
            return util.exportExcel(list, "settlement");
    }

    /**
     * 获取【请填写功能名称】详细信息
     */
//    @PreAuthorize("@ss.hasPermi('system:settlement:query')")
    @GetMapping(value = "/{id}")
    @ApiOperation("获取【请填写功能名称】详细信息")
    public AjaxResult getInfo(@PathVariable("id") Long id)
    {
            return AjaxResult.success(vendorSettlementService.selectVendorSettlementById(id));
    }

    /**
     * 新增【请填写功能名称】
     */
//    @PreAuthorize("@ss.hasPermi('system:settlement:add')")
    @PostMapping("/getNewSettlement")
    @ApiOperation("新增【请填写功能名称】")
    @RepeatSubmit
    @Transactional(rollbackFor = Exception.class)
    public AjaxResult getNewSettlement(VendorSettlement query)
    {
        List<VendorSettlement> settlement = vendorSettlementService.getNewSettlement(query);
        return AjaxResult.success(settlement);
    }

    /**
     * 新增【请填写功能名称】
     */
//    @PreAuthorize("@ss.hasPermi('system:settlement:add')")
    @PostMapping
    @ApiOperation("新增【请填写功能名称】")
    @RepeatSubmit
    @Transactional(rollbackFor = Exception.class)
    public AjaxResult add(@RequestBody VendorSettlement vendorSettlement)
    {
            return toAjax(vendorSettlementService.insertVendorSettlement(vendorSettlement));
    }

    /**
     * 修改【请填写功能名称】
     */
//    @PreAuthorize("@ss.hasPermi('system:settlement:edit')")
    @PutMapping
    @ApiOperation("修改【请填写功能名称】")
    @RepeatSubmit
    @Transactional(rollbackFor = Exception.class)
    public AjaxResult edit(@RequestBody VendorSettlement vendorSettlement)
    {
            return toAjax(vendorSettlementService.updateVendorSettlement(vendorSettlement));
    }

    /**
     * 删除【请填写功能名称】
     */
//    @PreAuthorize("@ss.hasPermi('system:settlement:remove')")
	@DeleteMapping("/{ids}")
    @ApiOperation("删除【请填写功能名称】")
    @RepeatSubmit
    @Transactional(rollbackFor = Exception.class)
    public AjaxResult remove(@PathVariable Long[] ids)
    {
            return toAjax(vendorSettlementService.deleteVendorSettlementByIds(ids));
    }
}
